package com.quanxiaoha.weblog.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 使用enum关键字创建枚举类
 */
@Getter
@AllArgsConstructor
public enum FeelingEnum {
    UGLY(1, "丑陋"),
    SHIT(2, "不爽"),
    NORMAL(3, "一般"),
    HAPPY(4, "开心"),
    GREAT(5, "伟大");


    // 实例对象属性
    private Integer code;
    private String name;



    public static String getNameByCode(Integer code){
        String name = "code不存在";
        FeelingEnum[] FeelingEnums = FeelingEnum.values();
        for (FeelingEnum FeelingEnum : FeelingEnums) {
            if(FeelingEnum.getCode().equals(code)){
                name =  FeelingEnum.getName();
                break;
            }
        }
        return name;
    }
    
}
